//
//  DataStorage.m
//  HandyDialer
//
//	Developed by Team Synergy
//  Created by Jordan Tseng on 10/29/11.
//  Coders: Jacky Li and Jordan Tseng 
//  Graphic Designer: Derek Fong
//  Developers: Brad Lisson, Derek Fong, Jacky Li, Jeremy Gangoso, Jordan Tseng
//  Copyright HandyDialer 2011. All rights reserved.
//


#import "DataStorage.h"

static DataStorage *sharedInstance = nil;

@implementation DataStorage

+ (DataStorage *)sharedData
{
	@synchronized (self)
	{
		if (sharedInstance == nil)
			[[self alloc] init];
	}
	return sharedInstance;
}

+ (id)allocWithZone:(NSZone *)zone
{
	@synchronized(self)
	{
		if (sharedInstance == nil)
		{
			sharedInstance = [super allocWithZone:zone];
			return sharedInstance;
		}
	}
	return nil;
}

- (id)copyWithZone:(NSZone *)zone
{
	return self;
}

- (id)retain
{
	return self;
}

- (oneway void)release
{
	// do nothing
}

- (id)autorelease
{
	return self;
}

- (NSUInteger)retainCount
{
	return NSUIntegerMax;
}

- (id)init
{
	@synchronized(self)
	{
		[super init];
		//custom initialization here
		return self;
	}
}

- (void)setReverseNumber:(NSString *)number
{
	@synchronized(self)
	{
		if (reverseNumber != number)
		{
			[reverseNumber release];
			reverseNumber = [number retain];
		}
	}
}

- (NSString *)getReverseNumber
{
	@synchronized(self)
	{
		return reverseNumber;
	}
}

- (void)setSearchName:(NSString *)name;
{
	@synchronized(self)
	{
		if (searchName != name)
		{
			[searchName release];
			searchName = [name retain];
		}
	}
}
- (NSString *)getSearchName;
{
	@synchronized(self)
	{
		return searchName;
	}
}

- (void)setCurrentContact:(ABRecordRef)record
{
	@synchronized(self)
	{
		if(currentContact != record)
		{
			currentContact = record;
		}
	}
}

- (ABRecordRef)getCurrentContact
{
		@synchronized(self)
		{
			return currentContact;
		}
}


@end
